﻿using MaterialManagement.API.Application.Command.ERP;
using MaterialManagement.API.Dtos;
using MaterialManagement.Domain.ERP;
using MaterialManagement.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MaterialManagement.API.Controllers
{
    /// <summary>
    /// 领料控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PinkingController : ControllerBase
    {
        private readonly IMediator mediator;

        public PinkingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 新增领料单信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> CreateOutboundRecord(CreateOutboundRecordCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除领料单信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<int>> DelOutboundRecord([FromQuery]DelOutboundRecordCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改出入库状态 并更新物料库存
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<int>> UpdStateMaterialRequisition([FromQuery]UpdStateMaterialRequisitionCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 显示领料单信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIPaging<OutboundRecordModel>> GetPinkingOrder([FromQuery] GetPinkingOrderCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<APIResult<List<PinkingOrderDto>>> GetCodePinkingOrder([FromQuery] GetCodePinkingOrderCommand request)
        {
            return mediator.Send(request);
        }
    }
}
